export const deepCopy = (obj) => {
    let objClone = Array.isArray(obj) ? [] : {};
    if (obj && typeof obj === 'object') {
        for (let key in obj) {
            if (obj.hasOwnProperty(key)) {
                if (obj[key] && typeof obj[key] === 'object') {
                    objClone[key] = deepCopy(obj[key]);
                } else {
                    objClone[key] = obj[key];
                }
            }
        }
    }
    return objClone;
}

/**
 * 
 * @param data Object 需要更改的对象
 * @param value Array 需要更改的属性名
 * @param type String 更改成为的类型
 */
export const changeParamsType = (data, value, type) => {
    switch (type) {
        case 'number':
            value.forEach(item => data[item] = Number(data[item]));
            break;
        case 'string':
            value.forEach(item => data[item] = String(data[item]));
            break;
        case 'bool':
            value.forEach(item => data[item] = Boolean(data[item]));
            break;
        case 'json':
            value.forEach(item => data[item] = JSON.stringify(data[item]));
            break;
        case 'default':
            value.forEach(item => data[item] = JSON.parse(data[item]));
            break;
        default:
            break;
    }
    return data;
}